//
//  DDMessageMainCell.m
//  DingDongZP
//
//  Created by 王威 on 16/3/17.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

#import "DDMessageMainCell.h"
#import "NSDate+DateDisplayString.h"

@implementation DDMessageMainCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.userImageView = [[UIImageView alloc] init];
        self.userImageView.layer.masksToBounds = YES;
        self.userImageView.layer.cornerRadius = 25.f;
        self.userImageView.layer.borderColor = [UIColor grayColor].CGColor;
        self.userImageView.layer.borderWidth = 1.f;
        [self.contentView addSubview:_userImageView];
        
        self.nameLabel = [[UILabel alloc] init];
        self.nameLabel.textAlignment = NSTextAlignmentLeft;
        self.nameLabel.text = @"彭林香 @杭州进学教育";
        self.nameLabel.font = [UIFont systemFontOfSize:13.f];
        [self.contentView addSubview:_nameLabel];
        
        self.messageLabel = [[UILabel alloc] init];
        self.messageLabel.textAlignment = NSTextAlignmentLeft;
        self.messageLabel.text = @"联合阿里巴巴打造双十一招聘狂欢节";
        self.messageLabel.textColor = COLOR_FONT_DARK_GRAY;
        self.messageLabel.font = [UIFont systemFontOfSize:13.f];
        [self.contentView addSubview:_messageLabel];
        
        self.timeLabel = [[UILabel alloc] init];
        self.timeLabel.textAlignment = NSTextAlignmentRight;
        self.timeLabel.textColor = COLOR_FONT_LIGHT_GRAY;
        self.timeLabel.font = [UIFont systemFontOfSize:13.f];
        self.timeLabel.text = [NSDate dateToDisplayStringForDateString:@"2016-03-16 18:33"];
        [self.contentView addSubview:_timeLabel];
        
        WEAKSELF
        [self.userImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.mas_equalTo(@14.5);
            make.top.mas_equalTo(@8.f);
            make.size.mas_equalTo(CGSizeMake(50.f, 50.f));
        }];
        
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(weakSelf.userImageView.mas_right).and.offset(14.f);
            make.top.equalTo(weakSelf.userImageView).and.offset(6.f);
            make.width.equalTo(weakSelf).and.offset(-180);
            make.height.mas_equalTo(@18.f);
        }];
        
        [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.equalTo(weakSelf.nameLabel.mas_bottom).and.offset(3.f);
            make.left.equalTo(weakSelf.nameLabel);
            make.width.equalTo(weakSelf).and.offset(-100);
            make.height.equalTo(weakSelf.nameLabel);
        }];
        
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.right.equalTo(weakSelf).and.offset(-3);
            make.top.equalTo(weakSelf.nameLabel);
            make.width.mas_equalTo(@100);
            make.height.equalTo(weakSelf.nameLabel);
        }];
        
//        ESWeakSelf
//        [self.userImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//            ESStrongSelf
//            make.left.mas_equalTo(@14.5);
//            make.top.mas_equalTo(@8.f);
//            make.size.mas_equalTo(CGSizeMake(50.f, 50.f));
//        }];
//        
//        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            ESStrongSelf
//            make.left.equalTo(_self.userImageView.mas_right).and.offset(14.f);
//            make.top.equalTo(_self.userImageView).and.offset(6.f);
//            make.width.equalTo(_self).and.offset(-180);
//            make.height.mas_equalTo(@18.f);
//        }];
//        
//        [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            ESStrongSelf
//            make.top.equalTo(_self.nameLabel.mas_bottom).and.offset(3.f);
//            make.left.equalTo(_self.nameLabel);
//            make.width.equalTo(_self).and.offset(-100);
//            make.height.equalTo(_self.nameLabel);
//        }];
//        
//        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            ESStrongSelf;
//            make.right.equalTo(_self).and.offset(-3);
//            make.top.equalTo(_self.nameLabel);
//            make.width.mas_equalTo(@100);
//            make.height.equalTo(_self.nameLabel);
//        }];

        
    }
    return self;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
